-
Notifications
You must be signed in to change notification settings - Fork 600
graph interrupts #1350
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
graph interrupts #1350
Conversation
Add comprehensive interrupt handling and resume functionality to the Graph class: - Import and initialize _InterruptState to track interrupt state across invocations - Call interrupt_state.resume() at the start of invoke() to properly resume interrupted tasks - Track MultiAgentNodeInterruptEvent occurrences during graph execution - Pass interrupts to _build_result() for inclusion in final result - Fix resume state management by only clearing flags on COMPLETED/FAILED status - Create a copy of _resume_next_nodes to prevent clearing the list being iterated - Add detailed debug logging for resume state at execution start - Detect interrupts during batch execution and break out early when detected This enables graphs to be properly interrupted mid-execution and resumed from the exact point of interruption, maintaining state consistency across session boundaries.
|
Looking forward to this PR being merged. Thanks @msalehan |
|
@zastrowm @afarntrog I am working on a use case where HIL is needed in graph pattern, is there any plan to merge this PR anytime soon? |
|
@msalehan This PR looks fantastic — the interrupt support for Graphs is exactly what we've been waiting for to enable reliable human-in-the-loop approvals in our multi-agent workflows. We're actively building production features that depend on this capability and are blocked without it. Could we please get this reviewed and merged as soon as possible? We'd really appreciate any priority it can get! Thanks so much for the great work! |
|
Unfortunately, we can’t wait for this feature to be released, so we’ve had to switch to using LangGraph. |
Same here, I have started to explore other frameworks which support HIL in graph pattern, because this PR doesn't seem to be prioritized anytime soon. |
|
Thanks for your interest in this PR. The team said that they are going to look at it soon. |
Description
Here's the completed PR description:
Description
Add interrupt support for Graph multi-agent pattern, following the same implementation pattern as Swarm (PR #1193).
Implementation Changes:
src/strands/multiagent/graph.py:graphreference toGraphNodefor interrupt state restorationGraphNode.reset_executor_state()to restore from interrupt context (messages, state, interrupt_state)Graph.__init__()to set graph reference on all nodes_execute_node()to distinguish between hook interrupts (activated=False) and agent interrupts (activated=True)_activate_interrupt()to save agent's actual activated flag (not hardcoded True)_execute_node()to properly restore node stateTest Coverage:
tests/strands/multiagent/test_graph.py:test_graph_interrupt_on_before_node_call_event- Hook-based interrupttest_graph_interrupt_on_agent- Agent tool interrupttests_integ/interrupts/multiagent/test_hook.py:test_graph_interrupt- Full end-to-end with approvaltest_graph_interrupt_reject- Rejection with cancellationThis enables graphs to be properly interrupted mid-execution (via hooks or agent tools) and resumed from the exact point of interruption, maintaining state consistency.
Related Issues
#204
Documentation PR
None
Type of Change
New feature
Testing
How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli
hatch run prepareChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.